<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body">

        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">广告名称</label>
            <label class="layui-col-xs10">
                <input name="title"  value='{$vo.title|default=""}' placeholder="请输入兼职分类名称" class="layui-input">
            </label>
        </div>
        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">banner图片</label>
            <label class="layui-col-xs8 think-form-group-left">
                <input name="logo"  value='{$vo.logo|default=""}' placeholder="请上传分类图片" class="layui-input">
            </label>
            <a class="layui-col-xs2 layui-btn think-form-group-right" data-file="btn" data-field="logo" data-type="png,jpg,gif">
                <i class="layui-icon layui-icon-upload"></i> 上传图片
            </a>
        </div>
        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">选择广告位</label>
            <label class="layui-col-xs10">
              <select class="layui-col-xs10"  name="tid" lay-search>
                {foreach $cates as $cate}
                  {if isset($vo.tid) and $vo.tid eq $cate.id}
                  <option selected value="{$cate.id}">{$cate.title|default=''}</option>
                  {else}
                  <option value="{$cate.id}">{$cate.title|default=''}</option>
                  {/if}
                {/foreach}
              </select>
            </label>
        </div>
        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">广告链接</label>
            <label class="layui-col-xs10">
                 <input name="linkurl" type="url" value='{$vo.linkurl|default=""}'  placeholder="请输入广告链接" class="layui-input">
            </label>
        </div>

        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">排序</label>
            <label class="layui-col-xs10">
                 <input name="sort" type="number" value='{$vo.sort|default=""}' placeholder="请输入数值" class="layui-input">
            </label>
        </div>
        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">广告类型</label>
            <label class="layui-col-xs2">
                <input class="banner" name="type" value="1" title="全国" {eq name='vo.type|default="1"' value='1'} checked {/eq} type="radio">            
            </label>
            <label class="layui-col-xs2">
             <input class="banner" name="type" value="0" title="地区" {eq name='vo.type|default="1"' value='0'} checked {/eq}  type="radio">
         </label>
        </div>

        <div class="layui-row margin-bottom-15 banner_type" {eq name='vo.type|default="1"' value='1'} style="display: none;" {/eq} >
            <label class="layui-col-xs2 think-form-label">选择广告地区</label>
            <label class="layui-col-xs10">
              <select class="layui-col-xs10"  name="agency_id" lay-search>
                {foreach $areas as $area}
                  {if isset($vo.agency_id) and $vo.agency_id eq $area.id}
                  <option selected value="{$area.id}">{$area.username|default=''}-{$area.province|default=''}-{$area.city|default=''}</option>
                  {else}
                  <option value="{$area.id}">{$area.username|default=''}-{$area.province|default=''}-{$area.city|default=''}</option>
                  {/if}
                {/foreach}
              </select>
            </label>
        </div>


        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">广告有效期</label>
            {notempty name='$vo.id'}

            <label class="layui-col-xs4">
                <input name="start_time" id="test1" placeholder="开始时间" value="{$vo.start_time|date='Y-m-d'}
"  autocomplete="off" class="layui-input" type="text">
            </label>
            <label class="layui-col-xs4" style="margin-left: 5px;">
                <input name="end_time" id="test2" placeholder="截止时间" value="{$vo.end_time|date='Y-m-d'}"  autocomplete="off" class="layui-input" type="text">
            </label>
            {else /}
                        <label class="layui-col-xs4">
                <input name="start_time" id="test1" placeholder="开始时间" value="{$vo.start_time|default=''}
"  autocomplete="off" class="layui-input" type="text">
            </label>
            <label class="layui-col-xs4" style="margin-left: 5px;">
                <input name="end_time" id="test2" placeholder="截止时间" value="{$vo.end_time|default=''}"  autocomplete="off" class="layui-input" type="text">
            </label>
            {/notempty}
        </div>

        <div class="layui-row margin-bottom-15">
            <label class="layui-col-xs2 think-form-label">状态</label>
            <label class="layui-col-xs2">
                <input name="status" value="1" title="启用" {eq name='vo.status|default="1"' value='1'} checked {/eq} type="radio">            
            </label>
            <label class="layui-col-xs2">
             <input name="status" value="0" title="禁用" {eq name='vo.status|default="1"' value='0'} checked {/eq}  type="radio">
         </label>
        </div>



    </div>

    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>
<script type="text/javascript">
    window.form.render();
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
          elem: '#test1'
        });
        laydate.render({
          elem: '#test2'
        });
    });


    $(function(){
        $(".banner").click(function(){
            var btype=$("input[name='type']:checked").val();
            if(btype==1){
                $(".banner_type").hide();
            }else{
                $(".banner_type").show();
            }
        })
    })
</script>